package cn.gson.crm.control;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.gson.crm.service.InveService;
import cn.gson.crm.vo.InveInfoTbVo;
import cn.gson.crm.vo.InveTbVo;

@Controller
@RequestMapping
public class InveController {

	@Autowired
	InveService invese;
	
	@RequestMapping("/toinve")
	public String test(){
		return "xp/Inve";
	}
	
	
	
	@GetMapping("/get_all_inves_page")
	@ResponseBody
	public Map<Object, Object> getAllinvesPage(int page,int rows){
		Map<Object, Object> map=new HashMap<>();
		PageHelper pHelper = new PageHelper();
		pHelper.startPage(page, rows);
	
		PageInfo<InveTbVo> pInfo = new PageInfo<>(invese.getAllinveBypage());//这个里面只查出十条数据
		
	/*	List<InveTbVo> list =invese.getAllinveBypage(page, rows);*/
/*		long count=invese.count();
		map.put("total", count);
		map.put("rows", list);*/
		long count=invese.count();
		map.put("total", count);//条数
		map.put("rows", pInfo.getList());

		return map;
	}
	@GetMapping("/get_all_inves_page_where1")
	@ResponseBody
		public Map<Object,Object> getAllinvesinfoPagewhere(int page,int rows){
			Map<Object, Object> map=new HashMap<>();
				List<InveInfoTbVo>list=invese.getAllInveinfos(page,rows);
				long count=invese.count1();
				map.put("total", count);
				map.put("rows", list);
				return map;
	
	}
@GetMapping("/get_all_inves_page_where")
@ResponseBody
	public Map<Object,Object> getAllinvesPagewhere(int page,int rows,Long key){
		Map<Object, Object> map=new HashMap<>();
	
			List<InveInfoTbVo>list=invese.getAllInveinfosBykey(page,rows,key);
			long count=invese.countwhere(key);
			map.put("total", count);
			map.put("rows", list);
			return map;
	}
}
